<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: cookie  YAHOO.util.Cookie   (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
    <script type="text/javascript" src="assets/api-js"></script>
    <script type="text/javascript" src="assets/ac-js"></script>
</head>

<body id="yahoo-com">

<div id="doc3" class="yui-t2">

	<div id="hd">
        <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
        <h3>cookie&nbsp; <span class="subtitle">2.6.0</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_cookie.html">cookie</a>
                 &gt; YAHOO.util.Cookie 
                
            </p>


	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">
            <form name="yui-classopts-form">
    <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> <label for="showprivate">Show Private</label></span>
    <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> <label for="showprotected">Show Protected</label></span>
    <span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> <label for="showdeprecated">Show Deprecated</label></span>
            </form>

                    <h2>
                        

                        <code>static</code>
                        
                            Class <b>YAHOO.util.Cookie</b>
                        <span class="extends">
                        </span>

                        <span class="extends">
                        </span>
                        
                        </code>
                    </h2>
                    <!-- class tree goes here -->
                    
                
  

                    <div class="summary description">
                        Cookie utility.
                    </div>




                        <div class="section method details">
                            <h3 id="methods">Methods</h3>
                            <div class="content">
                                    <div class="private">
                                    <h4>
                                        <a name="method__createCookieHash">_createCookieHash</a></h4>
                                    <div class="detail">
                                        <code>
                                         private 
                                         static 
                                        
                                        String
                                            <strong>_createCookieHash</strong>
                                           (
                                                
                                                        
                                                         hash
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Formats a cookie value for an object containing multiple values.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>hash &lt;Object&gt;</code>
                                                             An object of key-value pairs to create a string for.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        String
                                                    </code></dt>
                                                    <dd>A string suitable for use as a cookie value.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="private">
                                    <h4>
                                        <a name="method__createCookieString">_createCookieString</a></h4>
                                    <div class="detail">
                                        <code>
                                         private 
                                         static 
                                        
                                        String
                                            <strong>_createCookieString</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                                        , 
                                                         value
                                                    
                                                
                                                        , 
                                                         encodeValue
                                                    
                                                
                                                        , 
                                                         options
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Creates a cookie string that can be assigned into document.cookie.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie.
                                                        </dd>
                                                        <dd>
                                                            <code>value &lt;String&gt;</code>
                                                             The value of the cookie.
                                                        </dd>
                                                        <dd>
                                                            <code>encodeValue &lt;encodeValue&gt;</code>
                                                             True to encode the value, false to leave as-is.
                                                        </dd>
                                                        <dd>
                                                            <code>options &lt;Object&gt;</code>
                                                             (Optional) Options for the cookie.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        String
                                                    </code></dt>
                                                    <dd>The formatted cookie string.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="private">
                                    <h4>
                                        <a name="method__parseCookieHash">_parseCookieHash</a></h4>
                                    <div class="detail">
                                        <code>
                                         private 
                                         static 
                                        
                                        Object
                                            <strong>_parseCookieHash</strong>
                                           (
                                                
                                                        
                                                         text
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Parses a cookie hash string into an object.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>text &lt;String&gt;</code>
                                                             The cookie hash string to parse. The string should already be URL-decoded.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        Object
                                                    </code></dt>
                                                    <dd>An object containing entries for each cookie value.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="private">
                                    <h4>
                                        <a name="method__parseCookieString">_parseCookieString</a></h4>
                                    <div class="detail">
                                        <code>
                                         private 
                                         static 
                                        
                                        Object
                                            <strong>_parseCookieString</strong>
                                           (
                                                
                                                        
                                                         text
                                                    
                                                
                                                        , 
                                                         decode
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Parses a cookie string into an object representing all accessible cookies.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>text &lt;String&gt;</code>
                                                             The cookie string to parse.
                                                        </dd>
                                                        <dd>
                                                            <code>decode &lt;Boolean&gt;</code>
                                                             (Optional) Indicates if the cookie values should be decoded or not. Default is true.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        Object
                                                    </code></dt>
                                                    <dd>An object containing entries for each accessible cookie.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_get">get</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                         static 
                                        
                                        Variant
                                            <strong>get</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                                        , 
                                                         converter
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Returns the cookie value for the given name.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie to retrieve.
                                                        </dd>
                                                        <dd>
                                                            <code>converter &lt;Function&gt;</code>
                                                             (Optional) A function to run on the value before returning
it. The function is not used if the cookie doesn't exist.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        Variant
                                                    </code></dt>
                                                    <dd>If no converter is specified, returns a string or null if
the cookie doesn't exist. If the converter is specified, returns the value
returned from the converter or null if the cookie doesn't exist.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_getHash">getHash</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                         static 
                                        
                                        Object
                                            <strong>getHash</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Returns an object containing name-value pairs stored in the cookie with the given name.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie to retrieve.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        Object
                                                    </code></dt>
                                                    <dd>An object of name-value pairs if the cookie with the given name
exists, null if it does not.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_getSub">getSub</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                         static 
                                        
                                        Variant
                                            <strong>getSub</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                                        , 
                                                         subName
                                                    
                                                
                                                        , 
                                                         converter
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Returns the value of a subcookie.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie to retrieve.
                                                        </dd>
                                                        <dd>
                                                            <code>subName &lt;String&gt;</code>
                                                             The name of the subcookie to retrieve.
                                                        </dd>
                                                        <dd>
                                                            <code>converter &lt;Function&gt;</code>
                                                             (Optional) A function to run on the value before returning
it. The function is not used if the cookie doesn't exist.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        Variant
                                                    </code></dt>
                                                    <dd>If the cookie doesn't exist, null is returned. If the subcookie
doesn't exist, null if also returned. If no converter is specified and the
subcookie exists, a string is returned. If a converter is specified and the
subcookie exists, the value returned from the converter is returned.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_remove">remove</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                         static 
                                        
                                        String
                                            <strong>remove</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                                        , 
                                                         options
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Removes a cookie from the machine by setting its expiration date to
sometime in the past.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie to remove.
                                                        </dd>
                                                        <dd>
                                                            <code>options &lt;Object&gt;</code>
                                                             (Optional) An object containing one or more
cookie options: path (a string), domain (a string), 
and secure (true/false). The expires option will be overwritten
by the method.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        String
                                                    </code></dt>
                                                    <dd>The created cookie string.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_removeSub">removeSub</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                         static 
                                        
                                        String
                                            <strong>removeSub</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                                        , 
                                                         subName
                                                    
                                                
                                                        , 
                                                         options
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Removes a sub cookie with a given name.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie in which the subcookie exists.
                                                        </dd>
                                                        <dd>
                                                            <code>subName &lt;String&gt;</code>
                                                             The name of the subcookie to remove.
                                                        </dd>
                                                        <dd>
                                                            <code>options &lt;Object&gt;</code>
                                                             (Optional) An object containing one or more
cookie options: path (a string), domain (a string), expires (a Date object),
and secure (true/false). This must be the same settings as the original
subcookie.
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        String
                                                    </code></dt>
                                                    <dd>The created cookie string.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_set">set</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                         static 
                                        
                                        String
                                            <strong>set</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                                        , 
                                                         value
                                                    
                                                
                                                        , 
                                                         options
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Sets a cookie with a given name and value.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie to set.
                                                        </dd>
                                                        <dd>
                                                            <code>value &lt;Variant&gt;</code>
                                                             The value to set for the cookie.
                                                        </dd>
                                                        <dd>
                                                            <code>options &lt;Object&gt;</code>
                                                             (Optional) An object containing one or more
cookie options: path (a string), domain (a string), expires (a Date object),
and secure (true/false).
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        String
                                                    </code></dt>
                                                    <dd>The created cookie string.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_setSub">setSub</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                         static 
                                        
                                        String
                                            <strong>setSub</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                                        , 
                                                         subName
                                                    
                                                
                                                        , 
                                                         value
                                                    
                                                
                                                        , 
                                                         options
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Sets a sub cookie with a given name to a particular value.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie to set.
                                                        </dd>
                                                        <dd>
                                                            <code>subName &lt;String&gt;</code>
                                                             The name of the subcookie to set.
                                                        </dd>
                                                        <dd>
                                                            <code>value &lt;Variant&gt;</code>
                                                             The value to set.
                                                        </dd>
                                                        <dd>
                                                            <code>options &lt;Object&gt;</code>
                                                             (Optional) An object containing one or more
cookie options: path (a string), domain (a string), expires (a Date object),
and secure (true/false).
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        String
                                                    </code></dt>
                                                    <dd>The created cookie string.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                                    <div class="">
                                    <h4>
                                        <a name="method_setSubs">setSubs</a></h4>
                                    <div class="detail">
                                        <code>
                                        
                                         static 
                                        
                                        String
                                            <strong>setSubs</strong>
                                           (
                                                
                                                        
                                                         name
                                                    
                                                
                                                        , 
                                                         value
                                                    
                                                
                                                        , 
                                                         options
                                                    
                                                
                                            )
                                        </code>
                                        
                                        <div class="description">
                                            Sets a cookie with a given name to contain a hash of name-value pairs.
                                        </div>

                                        <div class="description">

                                                <dl>
                                                    <dt>Parameters:</dt>
                                                        <dd>
                                                            <code>name &lt;String&gt;</code>
                                                             The name of the cookie to set.
                                                        </dd>
                                                        <dd>
                                                            <code>value &lt;Object&gt;</code>
                                                             An object containing name-value pairs.
                                                        </dd>
                                                        <dd>
                                                            <code>options &lt;Object&gt;</code>
                                                             (Optional) An object containing one or more
cookie options: path (a string), domain (a string), expires (a Date object),
and secure (true/false).
                                                        </dd>
                                                </dl>

                                                <dl>
                                                    <dt>Returns:
                                                    <code>
                                                        String
                                                    </code></dt>
                                                    <dd>The created cookie string.</dd>
                                                </dl>


             

                                        </div>

                                    </div>
                                    <hr />
                                    </div>
                            </div>
                        </div>







			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class=""><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_carousel.html">carousel</a></li>

                                <li class=""><a href="module_charts.html">charts</a></li>

                                <li class=""><a href="module_colorpicker.html">colorpicker</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class=""><a href="module_container.html">container</a></li>

                                <li class="selected"><a href="module_cookie.html">cookie</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class=""><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_editor.html">editor</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_get.html">get</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_imagecropper.html">imagecropper</a></li>

                                <li class=""><a href="module_imageloader.html">imageloader</a></li>

                                <li class=""><a href="module_json.html">json</a></li>

                                <li class=""><a href="module_layout.html">layout</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_paginator.html">paginator</a></li>

                                <li class=""><a href="module_profiler.html">profiler</a></li>

                                <li class=""><a href="module_profilerviewer.html">profilerviewer</a></li>

                                <li class=""><a href="module_resize.html">resize</a></li>

                                <li class=""><a href="module_selector.html">selector</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_uploader.html">uploader</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>

                                <li class=""><a href="module_yuiloader.html">yuiloader</a></li>

                                <li class=""><a href="module_yuitest.html">yuitest</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class="selected"><a href="YAHOO.util.Cookie.html">YAHOO.util.Cookie</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="Cookie.js.html">Cookie.js</a></li>
                        </ul>
                    </div>


                    <div class="module">
                        <h4>Methods</h4>
                        <ul class="content">        
                                <li class="private"><!--<code>String</code>-->
                                <a href="#method__createCookieHash">_createCookieHash</a>
                                </li>
                                <li class="private"><!--<code>String</code>-->
                                <a href="#method__createCookieString">_createCookieString</a>
                                </li>
                                <li class="private"><!--<code>Object</code>-->
                                <a href="#method__parseCookieHash">_parseCookieHash</a>
                                </li>
                                <li class="private"><!--<code>Object</code>-->
                                <a href="#method__parseCookieString">_parseCookieString</a>
                                </li>
                                <li class=""><!--<code>Variant</code>-->
                                <a href="#method_get">get</a>
                                </li>
                                <li class=""><!--<code>Object</code>-->
                                <a href="#method_getHash">getHash</a>
                                </li>
                                <li class=""><!--<code>Variant</code>-->
                                <a href="#method_getSub">getSub</a>
                                </li>
                                <li class=""><!--<code>String</code>-->
                                <a href="#method_remove">remove</a>
                                </li>
                                <li class=""><!--<code>String</code>-->
                                <a href="#method_removeSub">removeSub</a>
                                </li>
                                <li class=""><!--<code>String</code>-->
                                <a href="#method_set">set</a>
                                </li>
                                <li class=""><!--<code>String</code>-->
                                <a href="#method_setSub">setSub</a>
                                </li>
                                <li class=""><!--<code>String</code>-->
                                <a href="#method_setSubs">setSubs</a>
                                </li>
                        </ul>
                    </div>



            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2008 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
